using System;

namespace Minesweeper
{
    class Program
    {
        static void Main()
        {
            int l, w, b, sum;
            int mouse_x = 0, mouse_y = 0;
            Get_parameter(out l, out w, out b);
            bool[,] dig = new bool[l, w];
            int[,] map = Make_empty_map(l, w);

            Console.Clear();

            sum = l * w;

            while (true)
            {
                Print_map(map, dig, l, w, mouse_x, mouse_y);

                switch (Console.ReadKey().Key)
                {
                    case ConsoleKey.UpArrow:
                        if (mouse_y - 1 >= 0) mouse_y--; break;

                    case ConsoleKey.DownArrow:
                        if (mouse_y + 1 < l) mouse_y++; break;

                    case ConsoleKey.LeftArrow:
                        if (mouse_x - 1 >= 0) mouse_x--; break;

                    case ConsoleKey.RightArrow:
                        if (mouse_x + 1 < w) mouse_x++; break;

                    case ConsoleKey.Spacebar:
                        {
                            if (sum == l * w)
                            {
                                // Make_booms(out map, l, w, b, mouse_x, mouse_y);
                            }
                            else
                            {
                            }
                            break;
                        }
                }
                // Console.SetCursorPosition(0, 0);
                Console.Clear();
                Console.WriteLine("++");
            }
        }

        /// <summary>
        /// 获取棋盘参数
        /// </summary>
        /// <param name="length">棋盘高</param>
        /// <param name="width">棋盘宽</param>
        /// <param name="booms">雷数</param>
        public static void Get_parameter(out int length, out int width, out int booms)
        {
            try
            {
                Console.WriteLine("请输棋盘高：");
                length = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("请输棋盘宽：");
                width = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("请输雷数：");
                booms = Convert.ToInt32(Console.ReadLine());
            }
            catch
            {
                Console.SetCursorPosition(0, 0);
                Console.WriteLine("请输入整数");
                Get_parameter(out length, out width, out booms);
            }
            return;
        }

        /// <summary>
        /// 制作空棋盘
        /// </summary>
        /// <param name="length">棋盘高</param>
        /// <param name="width">棋盘宽</param>
        /// <returns></returns>
        public static int[,] Make_empty_map(int length, int width)
        {
            return new int[length, width];
        }

        /// <summary>
        /// 打印棋盘
        /// </summary>
        /// <param name="map">棋盘数组</param>
        /// <param name="dig">探索数组</param>
        /// <param name="length">棋盘高</param>
        /// <param name="width">棋盘宽</param>
        /// <param name="mouse_x">光标x坐标</param>
        /// <param name="mouse_y">光标y坐标</param>
        public static void Print_map(int[,] map, bool[,] dig, int length, int width, int mouse_x, int mouse_y)
        {
            for (int y = 0; y < length; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    if (x == mouse_x && y == mouse_y)
                        Console.Write('>');
                    else
                        Console.Write(' ');
                    /*if (dig[y, x])
					{
						Console.Write(map[y, x].ToString());
					}
					else
					{
						Console.Write('#');
					}*/
                    if (map[y, x] < 10)
                        Console.Write(map[y, x]);
                    else
                        Console.Write("@");
                }
                Console.Write('\n');
            }
            Console.Write('\n');
            for (int y = 0; y < length; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    Console.Write(" {0}", map[y, x]);
                }
                Console.Write('\n');
            }
        }

        /*public static void Dig(int[,] map, bool[,] dig, int x, int y)
		{
			if(map[y,x] == 0)
			{

				for(int i=1;)
			}
		}*/

        public static void Make_booms(out int[,] map, int length, int width, int booms, int mouse_x, int mouse_y)
        {
            map = Make_empty_map(length, width);
            Random random = new Random();
            int x, y;
            while (booms > 0)
            {
                x = random.Next(width - 1);
                y = random.Next(length - 1);
                if (x != mouse_x && y != mouse_y)
                {
                }
            }
        }
    }
}
